package cn.iocoder.boot.service.impl;

import cn.iocoder.boot.entity.HttpRequestLog;
import cn.iocoder.boot.mapper.HttpRequestLogMapper;
import cn.iocoder.boot.service.HttpRequestLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class HttpRequestLogServiceImpl extends ServiceImpl<HttpRequestLogMapper, HttpRequestLog> implements HttpRequestLogService {

    /**
     * 保存日志
     *
     * @param url
     * @param keyword
     * @param requestData
     * @param responseData
     */
    @Override
    public void saveHttpRequestLog(String url, String keyword, String requestData, String responseData, Integer httpStatus) {
        HttpRequestLog httpRequestLog = new HttpRequestLog();
        httpRequestLog.setUrl(url);
        httpRequestLog.setKeyword(keyword);
        httpRequestLog.setRequestData(requestData);
        httpRequestLog.setResponseData(responseData);
        httpRequestLog.setHttpStatus(httpStatus);
        httpRequestLog.setCreatedTime(LocalDateTime.now());
        httpRequestLog.setUpdatedTime(LocalDateTime.now());
        this.save(httpRequestLog);
    }
}